/*
字典！
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;

char a[30],x[30],y[35];
map<string,string>q;

int main(){
	while(scanf("%s",a)!=EOF){
		if(*a=='\0'){
            break;
        }
		sscanf(a,"%s %s",&x,&y);
		q[y]=x;
	}
	while(scanf("%s",&x)==1){
		if(q.find(x)==q.end()){
            cout<<"eh"<<endl;
        }
		else{
            cout<<q[x]<<endl;
        }
	}
    return 0;
}

